package com.xxl.rpc.admin.demo;

import java.util.ArrayList;
import java.util.List;
import java.util.function.Function;
import java.util.function.IntPredicate;
import java.util.function.Supplier;
import java.util.stream.Collectors;

public class DemoSupplier {

    void test(){
        new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println("hello");
            }
        });

        new Thread(()->{
            System.out.println("hello");
        });
    }


   static void testSupplier(int age, Supplier<Emp> supplier){
        Emp emp =supplier.get();
        if (supplier.get().getAge()>age){
            emp.setAdultFlag(true);
        }
        emp.setAdultFlag(false);
    }

    public static void printNum(IntPredicate intPredicate){
        int[] arr={1,2,3,4,5,6,7};
        for (int i : arr) {
            if (intPredicate.test(i)){
                System.out.println(i);
            }
        }
    }


    static List<Emp> init(){
        List<Emp> list = new ArrayList<>();
        list.add(new Emp(15));
        list.add(new Emp(15));
        list.add(new Emp(19));
        return list;
    }

    static Double change(int base, Function<Integer,Double> function){
        Double res = function.apply(base);
        return res;
    }

    static Double cal(int base){
        Double res = base*1.2;
        return res;
    }

    public static void main(String[] args) {
//        List<Emp> list = init();
//        list.stream()
//                .distinct()
//                .filter(emp -> emp.getAge()>=18)
//                .collect(Collectors.toMap(emp -> emp.getAge(),emp -> emp));

//        testSupplier(18,()->{
//           return new Emp(19);
//        });

        Double res = change(1000, (Integer integer) -> {
                    return integer * 1.2;
        });
        System.out.println(res);
    }
}
